package com.daoeping.action;

import java.util.List;

import com.daoeping.data.Bsc_school;
import com.daoeping.data.Usr_education;
import com.daoeping.data.Usr_education;
import com.daoeping.service.Bsc_schoolService;
import com.daoeping.service.Usr_educationService;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

public class Usr_educationAction extends ActionSupport {
	private Usr_educationService usr_educationService;
	private Usr_education usr_education;
	
	private Bsc_schoolService bsc_schoolService;
	private Bsc_school bsc_school;
	
	public Usr_educationService getUsr_educationService() {
		return usr_educationService;
	}

	public void setUsr_educationService(Usr_educationService usr_educationService) {
		this.usr_educationService = usr_educationService;
	}

	public Usr_education getUsr_education() {
		return usr_education;
	}

	public void setUsr_education(Usr_education usr_education) {
		this.usr_education = usr_education;
	}

	public Bsc_schoolService getBsc_schoolService() {
		return bsc_schoolService;
	}

	public void setBsc_schoolService(Bsc_schoolService bsc_schoolService) {
		this.bsc_schoolService = bsc_schoolService;
	}
	
	public Bsc_school getBsc_school() {
		return bsc_school;
	}

	public void setBsc_school(Bsc_school bsc_school) {
		this.bsc_school = bsc_school;
	}

	public String addUsr_education(){
		this.bsc_schoolService.addBsc_school(bsc_school);
		
		usr_education.setBsc_school(bsc_school);
		this.usr_educationService.addUsr_education(usr_education);
		return "addUsr_education";
	}
	
	public String editUsr_education(){
		this.bsc_schoolService.editBsc_school(bsc_school);		
		usr_education.setBsc_school(bsc_school);

		this.usr_educationService.editUsr_education(usr_education);
		return "editUsr_education";
	}
	
	public String findUsr_educationByUserId(){
		//int user_id = Usr_education.getUsr_user().getId();	
		int user_id = 1;	
		Usr_education myUsr_education = ((List<Usr_education>)this.usr_educationService.findUsr_educationByUserId(user_id)).get(0);
		ActionContext.getContext().put("myUsr_education", myUsr_education);
		return "findUsr_educationByUserId";
	}
	
	public String findUsr_educationById(){
		//int id = usr_education.getId();	
		int id = 1;
		Usr_education myUsr_education = this.usr_educationService.findUsr_educationById(id).get(0);
		ActionContext.getContext().put("myUsr_education", myUsr_education);
		return "findUsr_educationById";
	}
}
